<?php
require_once 'Core/DBClass.php';

class ModuleBase{
	var $db;

	function __construct(){
		$this->db=DBClass::getInstance();
	}
	
	function _dishsave($model,$id,$obj){
		$d='Var/'.$model;
		if(!file_exists($d))
			mkdir($d);
		$p=$d.'/'.$id.'.json';
		if(file_exists($p))
			unlink($p);
		file_put_contents($p,json_encode($obj));
	}
	
	function _dishread($model,$id){
		$p='Var/'.$model.'/'.$id.'.json';
		if(file_exists($p)){
			return json_decode(file_get_contents($p));
		}
		return null;
	}
	
	function _dishclear($model,$id){
		$p='Var/'.$model.'/'.$id.'.json';
		if(file_exists($p))
			unlink($p);
	}
}
?>